#include "Jogador.h"

Jogador::~Jogador(void)
{
}

void Jogador::procKeyPressEvent(SDL_Event event)
{
	int vel = 10;
	
	switch( event.key.keysym.sym ) {
		case SDLK_RIGHT: 
			velX += vel;
			break;
		case SDLK_LEFT: 
			velX -= vel;
			break;
		case SDLK_UP: 
			velY -= vel;
			break;
		case SDLK_DOWN: 
			velY += vel;
			break;
	}
}

void Jogador::procKeyLetGoEvent(SDL_Event event)
{
	int vel = 10;
	
	switch( event.key.keysym.sym ) {
		case SDLK_RIGHT: 
			velX -= vel;
			break;
		case SDLK_LEFT: 
			velX += vel;
			break;
		case SDLK_UP: 
			velY += vel;
			break;
		case SDLK_DOWN: 
			velY -= vel;
			break;
	}
}

void Jogador::move(int limX, int limY)
{
	int newPosX, newPosY;
	newPosX = posX;
	newPosY = posY;
	
	newPosX += velX;
	newPosY += velY;
	
	if(newPosX < 0)
		newPosX = 0;
	else if(newPosX + sizeX > limX)
		newPosX = limX - sizeX;
	if(newPosY < 0)
		newPosY = 0;
	else if(newPosY + sizeY > limY)
		newPosY = limY - sizeY;
	
	posX = newPosX;
	posY = newPosY;
	
}




